<%@ page language="java" pageEncoding="UTF-8"%>
<!--分页查询共用的页面-->
<%@ include file="/common/paginateUtil.jsp"%>
</head>


<script type="text/javascript" charset="utf-8">


var veh_m = {};//定义对象


////////////////////////////////////////////////////////////////初始化控件
//接口，初始化控件
veh_m.initDivs = function(){
	this.initDepDiv();
	this.initRunStatusDiv();
	this.initSortDiv();
}

//初始化车组数据
veh_m.initDepDiv = function(){
	//创建下拉部门树
	Utility.createOrganzationTree("depId");
}

//初始化运行状态控件
veh_m.initRunStatusDiv = function(){
	$("#runStatus").lookup({ category: "runStatus" });

	$("#runStatus").change(function () {
		var txt = $("#runStatus").find("option:selected").text();
		$("#runStatusText").val(txt);
	});
}

//初始化排序控件
veh_m.initSortDiv = function(){
	$("#sortText").change(function () {
		var txt = $("#sortText").find("option:selected").text();
		$("#runStatusText").val(txt);
	});
}


////////////////////////////////////////////////////////////////获取数据
//查询按钮点击事件
veh_m.loadQueryDatas = function(){
	// Utility.loadGridWithParams();
	var queryForm = $("#queryForm").ajaxForm();
	console.log("queryForm = " , queryForm);
	 var formData = queryForm.formToArray();
	 console.log("formData = " , formData);
	 var queryParams = {};
	for(var m in formData){
		 queryParams[formData[m].name] = formData[m].value;        
	}

	console.log("queryParams = " , queryParams);

	 $("#queryGrid").datagrid("load", queryParams);
}


	

////////////////////////////////////////////////////////////////控件事件
//弹窗选择部门
veh_m.doSelectDep = function()
{
	InfoWindow.selectDep();
}
function onDepSelected(depId,depName)
{
	$("#depId").combotree("setValue", depId);
}

////////////////////////////////////////////////////////////////表格数据格式化
//删除表格的某一行，删除后，会自动刷新表格
veh_m.getDeleteActionColumn = function(value, rowData, rowIndex){
	var entityId = rowData.vehicleId;
	var html = "<img style='cursor: pointer;' src='<%=imgPath%>/cross.gif' onclick=\"Utility.deleteEntity('<%=ApplicationPath%>/vehicle/delete.action','" + entityId + "');\"/>";
	return html;
}
//编辑列
veh_m.getEditActionColumn = function(value, rowData, rowIndex){
	var entityId = rowData.vehicleId;
	var html = "<a href=\"javascript:InfoWindow.viewVehicle('" + entityId + "');\">" + " 编辑</a>";
	return html;
}
//查看驾驶员信息列
veh_m.getDriverActionColumn = function(value, rowData, rowIndex){
	var driverId = rowData.driverId;
	var driverName = rowData.driverName;
	if (driverId) {
		var html = "<a href=\"javascript:InfoWindow.viewDriverInfo('" + driverId + "');\">" + driverName + "</a>";
		return html;
	}else{
		return "";
	}
}
////////////////////////////////////////////////////////////////加载后执行
$(document).ready(function () {
	veh_m.initDivs();
	// Utility.loadGridWithParams();
		
});


</script>

		
<body>
<div id="toolbar">
	<form id="queryForm" action="<%=ApplicationPath%>/vehicle/paginate.action" method="POST">
		<input type="hidden" name="queryId" value="vehicle.selectVehicles" />
		<input type="hidden" name="fileName" value="车辆列表" />
		<input type="hidden" id="runStatusText" name="runStatusText" value="" />
		<input type="hidden" id="sortText" name="sortText" value="按车牌号排序" />

		<table width="100%" class="TableBlock">
			<tr>
				<td width="100" align="right"> 车牌号码: </td>
				<td width="150"> <input type="text" name="plateNo" size="20" id="plateNo"> </td>

				<td align="right">车辆组:</td>
				<td width="220">
					<select id="depId" name="depId" style="width:160px;"></select>
					<a id="btnSelectVehicle" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="veh_m.doSelectDep();"></a>
				</td>
				<td align="right">驾驶员名称:</td>
				<td><input type="text" name="driverName" size="20"> </td>
			</tr>
			<tr>
				<td align="right"> 终端卡号: </td>
				<td> <input type="text" name="simNo" size="20"> </td>

				<td align="right">运营状态</td>
				<td> <select id="runStatus" name="runStatus"></select>

				</td>
				<td align="right">排序:</td>
				<td><select id="sortBy" name="sortBy">
						<option value="plateNo">按车牌号排序</option>
						<option value="installDate">按安装时间排序</option>
						<option value="endDate">按到期时间排序</option>
					</select>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<a id="btnQuery" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="veh_m.loadQueryDatas();">查询</a>&nbsp;
					<a id="btnReset" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear'">重置</a>&nbsp;
					<a id="btnNew" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="InfoWindow.viewVehicle(0);">新增</a>&nbsp;
					<a id="btnExport" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="Utility.excelExport('<%=ApplicationPath%>/export.action');">导出</a>
					<!--调用utility.js-->
				</td>
			</tr>
		</table>
	</form>

</div>
<table id="queryGrid" class="easyui-datagrid" title="" style="width:100%;" data-options="pagination:true,pageSize:15,singleSelect:true,rownumbers:true,striped:true,fitColumns: true,
						pageList: [15, 20, 50, 100, 150, 200],fit:true,toolbar:'#toolbar',
						url:'<%=ApplicationPath%>/vehicle/paginate.action',method:'get'">
	<thead>
		<tr>
			<th data-options="field:'plateNo'" width="10">车牌号</th>
			<th data-options="field:'plateColor'" width="10">颜色</th>
			<th data-options="field:'simNo'" width="15">终端卡号</th>
			<th data-options="field:'driverName',formatter:veh_m.getDriverActionColumn" width="10">主驾驶</th>
			<th data-options="field:'runStatus'" width="10">运营状态</th>
			<th data-options="field:'depName1'" width="10">车组</th>
			<th data-options="field:'vehicleType'" width="10">车辆类型</th>
			<th data-options="field:'industryTypeName'" width="10">行业</th>
			<th data-options="field:'regionName'">车籍地</th>
			<th data-options="field:'installDate'">安装日期</th>
			<th data-options="field:'endDate'">到期时间</th>
			<th data-options="field:'1',formatter:veh_m.getEditActionColumn">编辑</th>
			<th data-options="field:'2',formatter:veh_m.getDeleteActionColumn">删除</th>
		</tr>
	</thead>
</table>

</body>

